//
// Decompiled by Jadx - 557ms
//
package fn;

import a.g;
import a.i;
import android.text.TextUtils;
import b.a;
import fm.d;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import me.plusne.GreenDao.dao.ConfigDao;
import me.plusne.GreenDao.dao.ConfigSystemDao;
import me.plusne.GreenDao.dao.RecordLogDao;
import me.plusne.common.Json.JsonHookStatic;
import org.greenrobot.greendao.database.DatabaseStatement;

public abstract class b extends y {
    public static final int b = 0;

    public static void c(int i, String str) {
        JsonHookStatic jsonHookStatic = y.by;
        RecordLogDao recordLogDao = jsonHookStatic.getDb().v;
        g o = androidx.activity.b.o(recordLogDao, recordLogDao);
        o.l(RecordLogDao.Properties.Key.f(str), new i[]{RecordLogDao.Properties.Type.f(Integer.valueOf(i))});
        o.i(1);
        fm.i iVar = (fm.i) o.k();
        if (iVar != null) {
            jsonHookStatic.getDb().h(iVar);
        }
    }

    public static void d(int i) {
        ArrayList arrayList;
        a aVar;
        JsonHookStatic jsonHookStatic = y.by;
        RecordLogDao recordLogDao = jsonHookStatic.getDb().v;
        g o = androidx.activity.b.o(recordLogDao, recordLogDao);
        o.l(RecordLogDao.Properties.Type.f(Integer.valueOf(i)), new i[0]);
        ArrayList j = o.j();
        RecordLogDao recordLogDao2 = jsonHookStatic.getDb().v;
        recordLogDao2.o();
        c j2 = ((x.a) recordLogDao2).l.j();
        ((x.a) recordLogDao2).h.c();
        try {
            synchronized (j2) {
                a aVar2 = ((x.a) recordLogDao2).j;
                if (aVar2 != null) {
                    aVar2.lock();
                    arrayList = new ArrayList();
                } else {
                    arrayList = null;
                }
                try {
                    Iterator it = j.iterator();
                    while (it.hasNext()) {
                        Object next = it.next();
                        Long c = recordLogDao2.c(next);
                        if (c == null) {
                            if (next == null) {
                                throw new NullPointerException("Entity may not be null");
                            }
                            throw new x.c("Entity has no key");
                        }
                        x.a.n(c, j2);
                        if (arrayList != null) {
                            arrayList.add(c);
                        }
                    }
                } finally {
                    a aVar3 = ((x.a) recordLogDao2).j;
                    if (aVar3 != null) {
                        aVar3.unlock();
                    }
                }
            }
            ((x.a) recordLogDao2).h.h();
            if (arrayList != null && (aVar = ((x.a) recordLogDao2).j) != null) {
                aVar.c(arrayList);
            }
        } finally {
            ((x.a) recordLogDao2).h.b();
        }
    }

    public static fm.i e(int i, String str) {
        if (str == null) {
            return null;
        }
        RecordLogDao recordLogDao = y.by.getDb().v;
        g o = androidx.activity.b.o(recordLogDao, recordLogDao);
        o.l(RecordLogDao.Properties.Key.f(str), new i[]{RecordLogDao.Properties.Type.f(Integer.valueOf(i))});
        o.i(1);
        return (fm.i) o.k();
    }

    public static int f(int i, String str) {
        JsonHookStatic jsonHookStatic = y.by;
        Object obj = jsonHookStatic.getSetList().get(str);
        if (obj != null) {
            try {
                return Integer.parseInt(String.valueOf(obj));
            } catch (NumberFormatException e) {
                e.printStackTrace();
                return i;
            }
        }
        if (jsonHookStatic.getDb() == null) {
            return i;
        }
        ConfigDao configDao = jsonHookStatic.getDb().q;
        configDao.getClass();
        g gVar = new g(configDao);
        gVar.l(ConfigDao.Properties.Key.f(str), new i[0]);
        gVar.i(1);
        fm.c cVar = (fm.c) gVar.k();
        if (cVar != null && !TextUtils.isEmpty(cVar.c)) {
            try {
                i = Integer.parseInt(cVar.c);
            } catch (NumberFormatException e2) {
                e2.printStackTrace();
                return i;
            }
        }
        jsonHookStatic.getSetList().put(str, Integer.valueOf(i));
        return i;
    }

    public static String g(String str, String str2) {
        String str3;
        JsonHookStatic jsonHookStatic = y.by;
        Object obj = jsonHookStatic.getSetList().get(str);
        if (obj != null) {
            return String.valueOf(obj);
        }
        if (jsonHookStatic.getDb() == null) {
            return str2;
        }
        ConfigDao configDao = jsonHookStatic.getDb().q;
        configDao.getClass();
        g gVar = new g(configDao);
        gVar.l(ConfigDao.Properties.Key.f(str), new i[0]);
        gVar.i(1);
        fm.c cVar = (fm.c) gVar.k();
        if (cVar != null) {
            str3 = cVar.c;
        } else {
            str3 = str2;
        }
        if (TextUtils.isEmpty(str3)) {
            str3 = str2.trim();
        }
        jsonHookStatic.getSetList().put(str, str3);
        return str3;
    }

    public static boolean h(String str, boolean z) {
        JsonHookStatic jsonHookStatic = y.by;
        Object obj = jsonHookStatic.getSetList().get(str);
        if (obj != null) {
            if (obj instanceof String) {
                return Boolean.parseBoolean((String) obj);
            }
            return ((Boolean) obj).booleanValue();
        }
        if (jsonHookStatic.getDb() == null) {
            return z;
        }
        ConfigDao configDao = jsonHookStatic.getDb().q;
        configDao.getClass();
        g gVar = new g(configDao);
        gVar.l(ConfigDao.Properties.Key.f(str), new i[0]);
        gVar.i(1);
        fm.c cVar = (fm.c) gVar.k();
        if (cVar != null) {
            z = Boolean.parseBoolean(cVar.c);
        }
        jsonHookStatic.getSetList().put(str, Boolean.valueOf(z));
        return z;
    }

    public static String i(String str) {
        JsonHookStatic jsonHookStatic = y.by;
        Object obj = jsonHookStatic.getSetListSys().get(str);
        if (obj != null) {
            return (String) obj;
        }
        String str2 = "";
        if (jsonHookStatic.getDb() == null) {
            return "";
        }
        ConfigSystemDao configSystemDao = jsonHookStatic.getDb().r;
        configSystemDao.getClass();
        g gVar = new g(configSystemDao);
        gVar.l(ConfigSystemDao.Properties.Key.f(str), new i[0]);
        gVar.i(1);
        d dVar = (d) gVar.k();
        if (dVar != null) {
            str2 = dVar.c;
        }
        jsonHookStatic.getSetListSys().put(str, str2);
        return str2;
    }

    public static void j(int i, String str, String str2) {
        k(str, i, str2, "");
    }

    public static void k(String str, int i, String str2, String str3) {
        JsonHookStatic jsonHookStatic = y.by;
        RecordLogDao recordLogDao = jsonHookStatic.getDb().v;
        g o = androidx.activity.b.o(recordLogDao, recordLogDao);
        o.l(RecordLogDao.Properties.Key.f(str), new i[]{RecordLogDao.Properties.Type.f(Integer.valueOf(i))});
        o.i(1);
        fm.i iVar = (fm.i) o.k();
        if (iVar == null) {
            fm.i iVar2 = new fm.i();
            iVar2.b = str;
            iVar2.c = str2;
            iVar2.d = i;
            iVar2.e = str3;
            jsonHookStatic.getDb().j(iVar2);
            return;
        }
        iVar.b = str;
        iVar.c = str2;
        iVar.d = i;
        iVar.e = str3;
        jsonHookStatic.getDb().l(iVar);
    }

    public static void l(Object obj, String str) {
        if (y.by.getDb() == null) {
            return;
        }
        synchronized (b.class) {
            o(obj, str);
            n(obj, str);
        }
    }

    public static void m(Object obj, String str) {
        HashMap setListSys;
        Object valueOf;
        JsonHookStatic jsonHookStatic = y.by;
        if (jsonHookStatic.getDb() == null) {
            return;
        }
        Object obj2 = jsonHookStatic.getSetListSys().get(str);
        if (obj2 != null) {
            if (obj2 instanceof Integer) {
                if (!(obj instanceof Integer)) {
                    setListSys = jsonHookStatic.getSetListSys();
                    valueOf = Integer.valueOf(Integer.parseInt((String) obj));
                    setListSys.put(str, valueOf);
                }
                jsonHookStatic.getSetListSys().put(str, obj);
            } else {
                if (obj2 instanceof Float) {
                    setListSys = jsonHookStatic.getSetListSys();
                    valueOf = Float.valueOf(Float.parseFloat((String) obj));
                } else if (obj2 instanceof Long) {
                    setListSys = jsonHookStatic.getSetListSys();
                    valueOf = Long.valueOf(Long.parseLong((String) obj));
                } else {
                    if (obj2 instanceof Double) {
                        setListSys = jsonHookStatic.getSetListSys();
                        valueOf = Double.valueOf(Double.parseDouble((String) obj));
                    }
                    jsonHookStatic.getSetListSys().put(str, obj);
                }
                setListSys.put(str, valueOf);
            }
        }
        if (obj != null) {
            ConfigSystemDao configSystemDao = jsonHookStatic.getDb().r;
            configSystemDao.getClass();
            g gVar = new g(configSystemDao);
            gVar.l(ConfigSystemDao.Properties.Key.f(str), new i[0]);
            gVar.i(1);
            d dVar = (d) gVar.k();
            if (dVar == null) {
                d dVar2 = new d();
                dVar2.b = str;
                dVar2.c = String.valueOf(obj);
                dVar2.d = obj.getClass().getName();
                jsonHookStatic.getDb().j(dVar2);
                return;
            }
            dVar.c = String.valueOf(obj);
            dVar.d = obj.getClass().getName();
            jsonHookStatic.getDb().l(dVar);
            return;
        }
        ConfigSystemDao configSystemDao2 = jsonHookStatic.getDb().r;
        configSystemDao2.getClass();
        g gVar2 = new g(configSystemDao2);
        gVar2.l(ConfigSystemDao.Properties.Key.f(str), new i[0]);
        gVar2.i(1);
        d dVar3 = (d) gVar2.k();
        if (dVar3 != null) {
            jsonHookStatic.getDb().h(dVar3);
        }
    }

    public static void n(Object obj, String str) {
        try {
            ConfigDao configDao = y.by.getDb().q;
            configDao.getClass();
            g gVar = new g(configDao);
            gVar.l(ConfigDao.Properties.Key.f(str), new i[0]);
            gVar.i(1);
            fm.c cVar = (fm.c) gVar.k();
            if (obj != null) {
                if (cVar == null) {
                    cVar = new fm.c();
                    cVar.b = str;
                }
                cVar.c = String.valueOf(obj);
                cVar.d = obj.getClass().getName();
                configDao.v(cVar);
                return;
            }
            if (cVar != null) {
                configDao.q(cVar);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void o(Object obj, String str) {
        JsonHookStatic jsonHookStatic = y.by;
        Object obj2 = jsonHookStatic.getSetList().get(str);
        if (obj2 != null) {
            HashMap setList = jsonHookStatic.getSetList();
            try {
                if ((obj2 instanceof Integer) && !(obj instanceof Integer)) {
                    obj = Integer.valueOf(Integer.parseInt(obj.toString()));
                } else if ((obj2 instanceof Float) && !(obj instanceof Float)) {
                    obj = Float.valueOf(Float.parseFloat(obj.toString()));
                } else if ((obj2 instanceof Long) && !(obj instanceof Long)) {
                    obj = Long.valueOf(Long.parseLong(obj.toString()));
                } else if ((obj2 instanceof Double) && !(obj instanceof Double)) {
                    obj = Double.valueOf(Double.parseDouble(obj.toString()));
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();
                obj = "";
            }
            setList.put(str, obj);
        }
    }

    public abstract void a();
}
